package factorypattern.factory;

import factorypattern.service.Shape;
import factorypattern.service.impl.Circle;
import factorypattern.service.impl.Rectangle;
import factorypattern.service.impl.Square;

/**
 * @Author： yu.Tan
 * @Date: 2020/9/30 16:14
 * @Description:
 */
public class ShapeFactory {

    //使用getShape方法获取形状类型的对象
    public Shape getShape(String shapeType) {
        if (shapeType == null) {
            return null;
        }
        if (shapeType.equalsIgnoreCase("CIRCLE")) {
            return new Circle();
        } else if (shapeType.equalsIgnoreCase("RECTANGLE")) {
            return new Rectangle();
        } else if (shapeType.equalsIgnoreCase("SQUARE")) {
            return new Square();
        }
        return null;
    }
}
